Skip to content

Conversation

@miguelgrinberg
Copy link
Contributor

@miguelgrinberg miguelgrinberg commented Nov 21, 2025

While debugging a YAML test failure in 8.19 I found that our parser does not appear to support variables, as opposite to expressions that are based on the response from the last request. Take the expression $profile.uid for example.

  • _lookup('$profile.uid') is called
  • value is assigned a dict that was a response in a previous operation
  • we enter the for-loop with step == '$profile'
  • the call to self._resolve(step) returns the value stored in self._state['profile'] and assigns it to step
  • the assert step in value fails

The changes to the parser add support for variables such as $profile. The value variable is only initialized to last_response when the expression does not start with a $, which means it is relative to that response. If the expression starts with $ we initialize to None. Then inside the loop we differentiate between a reference to a variable that starts the expression (when value is None) versus one that is in the middle and should be treated as a key lookup in the current value.

The issue that prompted this change is a block of match statements highlighted here: https://github.com/elastic/elasticsearch-clients-tests/blob/8.19/tests/security/50_user_profile.yml#L80-L86, which are currently failing.

@miguelgrinberg miguelgrinberg marked this pull request as draft November 21, 2025 14:43
@miguelgrinberg miguelgrinberg changed the title Add global variable support to YAML test expression parser Add variable support to YAML test expression parser Nov 21, 2025
Copy link
Member

@pquentin pquentin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM.

@miguelgrinberg miguelgrinberg merged commit 42f1834 into elastic:main Nov 24, 2025
19 checks passed
@miguelgrinberg miguelgrinberg deleted the yaml-test-expression-parser-fix branch November 24, 2025 10:33
github-actions bot pushed a commit that referenced this pull request Nov 24, 2025
github-actions bot pushed a commit that referenced this pull request Nov 24, 2025
github-actions bot pushed a commit that referenced this pull request Nov 24, 2025
github-actions bot pushed a commit that referenced this pull request Nov 24, 2025
miguelgrinberg added a commit that referenced this pull request Nov 24, 2025
…3205)

(cherry picked from commit 42f1834)

Co-authored-by: Miguel Grinberg <miguel.grinberg@gmail.com>
miguelgrinberg added a commit that referenced this pull request Nov 24, 2025
…3204)

(cherry picked from commit 42f1834)

Co-authored-by: Miguel Grinberg <miguel.grinberg@gmail.com>
miguelgrinberg added a commit that referenced this pull request Nov 24, 2025
…3203)

(cherry picked from commit 42f1834)

Co-authored-by: Miguel Grinberg <miguel.grinberg@gmail.com>
miguelgrinberg added a commit that referenced this pull request Nov 24, 2025
…3202)

(cherry picked from commit 42f1834)

Co-authored-by: Miguel Grinberg <miguel.grinberg@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants